Skip to content

refactor: repository structure & naming convention (#325) - #333

Merged
NitinKumar004 merged 15 commits into
developmentfrom
feat/structure-convention
Aug 6, 2026
Merged

refactor: repository structure & naming convention (#325)#333
NitinKumar004 merged 15 commits into
developmentfrom
feat/structure-convention

Conversation

@NitinKumar004

@NitinKumar004 NitinKumar004 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Implements the repository structure & naming convention from #325.

Convention (hybrid)

  • services/<capability> keeps the generic capability name (already the case).
  • providers/<cloud>/<service> and server/<cloud>/<service> use the service's real SDK name with no redundant cloud prefix (the parent aws/azure/gcp already encodes the cloud), and match each other within a cloud.
  • Files are snake_case, full words, with the same filename across layers.

The full rules live in the new docs/STRUCTURE.md (the source of truth contributors follow).

What's in this PR

  • docs/STRUCTURE.md — canonical-name table, file-naming rule, per-directory layout template, the driver/ rule (with documented exceptions), the sub-surface subdirectory rule, and a "where new code goes" checklist. Linked from the docs index.
  • Dropped every redundant cloud prefix on provider and wire directories: awsiam→iam; azure ai/cache/dns/iam/loadbalancer/monitor/search/sql; gcp iam/loadbalancer/vpc; and the matching server/azure/{ai,search,sql}. Package clauses, import paths, and service main files renamed to match.
  • snake_case feature filenames across provider + wire layers — nat_gateway.go, internet_gateway.go, elastic_ip.go, network_interface.go, transit_gateway.go, traffic_mirror.go, route_table.go, parameter_group.go, subnet_group.go, read_replica.go, managed_instance.go, app_service_plan.go, and ~90 more.
  • CI Structure job (scripts/check_structure.sh) that fails on any new cloud-prefixed provider/wire directory, so the convention self-enforces.
  • Provider↔wire name matching — provider and wire now share one name per service within a cloud, using the real SDK/API name: AWS load balancer → elbv2 (the mock is ALB/NLB v2); GCP → compute (compute.googleapis.com) and monitoring (monitoring.googleapis.com); azure blob→blobstorage, cosmos→cosmosdb, table→tablestorage, network→vnet; gcp networks→vpc. (Wire-only services with no provider mock — sts, resourcegraph, disks/snapshots, lro, … — are left as-is.)

No behavior change. These are directory/package/file renames plus the import fix-ups they require. go build, go vet, go test ./..., go mod tidy, and gofmt are all clean; the new structure check passes.

Sub-surface subdirectories — rule set for new services; existing mocks stay flat (§5)

STRUCTURE.md §5 documents the subdirectory rule and scopes it deliberately: it applies to new services designed that way, and existing large single-Mock providers (vpc, databricks) are an accepted flat exception. In Go a directory is a package, so promoting a sub-surface in providers/aws/vpc (256 methods, 57 fields under one mutex) would mean splitting the Mock into sub-packages — forcing a shared internal helper package, cross-surface callback injection, and a change to the single-lock concurrency model. That trades genuine behavior risk (lock semantics, dropped cascades) for a navigation win the per-feature snake_case files already deliver, and it isn't idiomatic Go. So these services keep one cohesive package with one <feature>.go per sub-surface; the rule guides new services going forward.

Addresses the documentation, no-cloud-prefix, file-naming (across all three layers), provider↔wire-matching, subdirectory-rule, and CI-guard acceptance criteria of #325.

…#325)

awsiam->iam; azure ai/cache/dns/iam/loadbalancer/monitor/search/sql;
gcp iam/loadbalancer/vpc. Directory + package renames only; no behavior change.
Feature files use snake_case full words across layers (transit_gateway.go,
traffic_mirror.go, prefix_list.go, route_table.go, elastic_ip.go, ...); renamed
service main files to match their new package (cache.go, sql.go, ...). File
renames only; no code or import changes.
…325)

Renames the remaining smashed multi-word feature files to snake_case full words
(nat_gateway, internet_gateway, elastic_ip, network_interface, transit_gateway,
route_table, parameter_group, subnet_group, read_replica, managed_instance,
app_service_plan, ...), and fixes import ordering after the directory renames.
File/import-ordering changes only; no behavior change.
elbv2->elb; azure blob->blobstorage, cosmos->cosmosdb, table->tablestorage,
network->vnet; gcp compute->gce, monitoring->cloudmonitoring, networks->vpc.
Provider<->wire now share a name within each cloud. Rename-only.
…325)

Corrects the provider<->wire match direction for three services: the wire layer
already carried the accurate SDK name. AWS elb->elbv2 (the mock is ALB/NLB v2);
GCP gce->compute (compute.googleapis.com); GCP cloudmonitoring->monitoring
(monitoring.googleapis.com). Provider and wire now both use the real name.
…wire (#325)

cognitive_services.go, machine_learning.go, feature_store.go, vector_search.go
in services/*/driver — restores same-filename-across-layers for these features.

@thzgajendra thzgajendra left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — repository structure & naming convention refactor (deep, multi-dimension pass)

Reviewed across behavior-preservation, dangling references, convention consistency, docs, silent breakage, naming design, test integrity, and cruft — plus a manual lead pass. Verdict: mechanically clean and behavior-preserving. I ran the full gate locally on the head: go build ./... ✓, go vet ./... ✓, go test ./... (all 225 pkgs) exit 0 ✓ (golangci-lint surfaced only wsl deprecation warnings, no errors). Coverage is preserved (0 test deletions; the apparent elbelbv2 / gce / cloudmonitoring "swaps" all land correctly with matching package decls), no logic was smuggled into any rename hunk (the awsiam.*→bare-iam rewrite in the external iam_test package correctly binds to the AWS SDK iam, not the local package), no back-compat shims, no empty/orphaned dirs, and the convention itself is sound — no stutter, since types are sql.Mock/iam.Mock not sql.SqlServer. Nice work; this is a careful migration.

Findings are documentation + minor consistency — nothing blocking.

Should address — docs now contradict the convention this PR makes canonical

This PR promotes STRUCTURE.md to "source of truth" and adds a blocking check_structure.sh CI gate — so stale docs will send contributors to dead paths / into CI failures. These weren't edited here, but the renames staled them:

  • docs/architecture.md (lines ~138, 158, 182–208, 238): the directory-tree diagrams still show awsiam/ azuremonitor/ azureiam/ azuredns/ azurelb/ azurecache/ azuresql/ gcpvpc/ gcpiam/ gcplb/ azureai/ azuresearch/.
  • docs/services.md (coverage matrix rows ~13–26; SQL section ~1503/1665–1676): old provider names.
  • docs/sdk-server.md:253: azuresql/sql/.
    Worth folding into this PR so the docs and the new gate agree on day one.

Minor consistency (introduced or left by this PR)

  • Struct fields keep the prefix the package dropped: providers/azure/azure.go:147-148AzureAI *ai.Mock, AzureSearch *search.Mock, while every sibling is unprefixed (IAM, DNS, SQL, Cache, Monitor, LB). Rename to AI/Search.
  • Primary filenames keep the old prefix in three Azure dirs: cache/azurecache.go, search/azuresearch.go, sql/azuresql.go (+azuresql_test.go) — whereas dns/dns.go, monitor/monitor.go, iam/iam.go, ai/ai.go dropped it. §4 wants the primary file = <service>.go; either rename or note the exception.
  • machinelearning_more.go sits next to machine_learning.go (in providers/azure/ai/ and the services driver) — snake_case (§3) applied unevenly.

Docs precision (in the new STRUCTURE.md)

  • §2.2 says provider/wire "keep the name that cloud's SDK uses," but the chosen leaves (cache, monitor, dns, sql) are not Azure's SDK names (rediscache, azuremonitor, cognitivesearch, …). Reword to "short capability name, no cloud prefix" — that's what the code actually does.
  • §5's traffic_mirror/ sub-surface example is hypothetical and contradicts the real flat layout (providers/aws/vpc/traffic_mirror.go, server/aws/ec2/traffic_mirror.go) and §5.2's own "vpc stays flat" rule. Label it illustrative or use a real example.
  • Two real exceptions the code makes but the doc doesn't call out: (a) AWS providers/aws/vpcserver/aws/ec2 name split (pre-existing and defensible — AWS's SDK puts VPC under EC2 — but §2.2's "same name" rule reads as absolute); (b) services/azureai/services/azuresearch stay prefixed while providers/azure/ai/search dropped it (fine if treated as product-specific per §2.1, but say so).

Consider — the new CI gate has blind spots

scripts/check_structure.sh uses a single-level glob (for path in "$dir"/*/) with no recursion, so a cloud-prefixed dir one level deeper — exactly the promoted-subdir layout §4 now permits — passes the gate; and it doesn't scan services/ at all. Worth hardening so the enforcement actually covers what the convention allows.

One thing I checked and cleared

A diff against a stale base made it look like the PR also adds ~155 files + 3 deps (artifactregistry/eventarc/storageaccount). It doesn't — the authoritative diff is 263 renames + exactly 2 new files (STRUCTURE.md, check_structure.sh); those services are already in development. Clean rename scope.

Bottom line: behavior-preserving, green across build/vet/test, and a sound convention. I'd just sync architecture.md/services.md/sdk-server.md (the gate makes that matter now) and mop up the small field/filename inconsistencies. Merge call is yours.

Moves the naming check into .github/workflows/ci.yml (no scripts/ folder) and
hardens it to recurse at any depth so a promoted sub-surface subdir can't
reintroduce a cloud prefix.
…ing_more filename (#325)

Provider fields AzureAI/AzureSearch -> AI/Search (matching unprefixed siblings);
machinelearning_more.go -> machine_learning_more.go (snake_case §3).
…recision (#325)

Update stale provider/wire dir names in the doc trees + coverage matrix; reword
STRUCTURE §2.2 (short name, not 'SDK name'), label §5 example illustrative, and
document the vpc<->ec2 and services/azureai product-name exceptions.
@NitinKumar004

Copy link
Copy Markdown
Collaborator Author

Thanks for the deep pass — all findings addressed in e8ecffc, bfb84ef, a98020c. Build/vet/go test ./.../gofmt all green.

CI gate

  • Dropped scripts/ — the Structure check is now inline in .github/workflows/ci.yml.
  • Hardened the blind spot — it now recurses at any depth under providers/<cloud>/server/<cloud>, so a promoted sub-surface subdir can't smuggle a cloud prefix back in. (I deliberately don't scan services/ for cloud prefixes: services/azureai/azuresearch are legitimate product names, not redundant prefixes — see the exception note below.)

Stale docs (synced to the new names)

  • docs/architecture.md — directory trees updated (awsiamiam, azuremonitormonitor, gcpvpcvpc, gcecompute, cloudmonitoringmonitoring, …).
  • docs/services.md — coverage matrix + SQL section.
  • docs/sdk-server.md:253azuresql/sql/.

Consistency

  • Provider fields AzureAI/AzureSearchAI/Search (matching every unprefixed sibling), with all accessors updated.
  • machinelearning_more.gomachine_learning_more.go (snake_case §3).
  • The three primary files (cache.go/search.go/sql.go) were already renamed after your snapshot — confirmed present, old names gone.

STRUCTURE.md precision

  • §2.2 reworded — "short service name, no cloud prefix (real SDK/CLI name where one clearly applies)" instead of "SDK name", and the table now reflects the corrected elbv2/compute/monitoring.
  • §5 example labeled illustrative, pointing at the real flat traffic_mirror.go layout.
  • Documented both exceptions you flagged: AWS providers/aws/vpcserver/aws/ec2 (SDK folds VPC under EC2), and services/azureai/azuresearch keeping the product name per §2.1.

Good catch on the elbv2/compute/monitoring direction too — those were corrected earlier in the PR to the real SDK/API names on both layers.

@thzgajendra thzgajendra left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — fixes in e8ecffc, bfb84ef, a98020c

Verified the delta in source (build ✓, vet ✓ on the changed trees). All ten original findings are resolved — and one of the fixes introduced a new CI regression that needs a one-line fix before merge.

Resolved ✓

Finding Status
Stale docs (architecture.md, services.md, sdk-server.md) ✅ Synced — grep for all old names across the three returns nothing
AzureAI/AzureSearch struct fields AI *ai.Mock / Search *search.Mock (azure.go:147-148); accessors + from_provider.go + tests updated
machinelearning_more.go snake_case machine_learning_more.go
Primary filenames (cache.go/search.go/sql.go) ✅ Confirmed present, old names gone
STRUCTURE.md §2.2 "SDK name" overclaim ✅ Reworded to "short service name, no cloud prefix" + table corrected (elbv2/compute/monitoring)
STRUCTURE.md §5 hypothetical example ✅ Labeled illustrative, points at the real flat layout
Undocumented exceptions (aws vpc↔ec2, services/azureai) ✅ Both now documented
CI gate blind spot (single-level glob, no recursion) ✅ Intent addressed (recurse any depth; services/ deliberately excluded — reasonable)

Nice, thorough turnaround, and I appreciate that you took the elbv2/compute/monitoring correction all the way to real SDK names on both layers.

⚠️ New regression — the Structure CI job is now broken (fix before merge)

e8ecffc deleted scripts/check_structure.sh but the workflow still invokes it:

# .github/workflows/ci.yml — structure job
      - name: naming & layout convention (docs/STRUCTURE.md)
        run: bash scripts/check_structure.sh

The script exists nowhere in the tree (find . -name check_structure.sh → empty), and there is no inline check in ci.yml — so the step runs bash scripts/check_structure.shNo such file or directory → exit 127 → the structure job fails on every run. The commit message says "inline the Structure check into the workflow," but the inline block didn't land; only the deletion did.

Fix: either (a) restore scripts/check_structure.sh (recursive version), or (b) actually inline it — replace that run: with the check body, e.g.:

        run: |
          fail=0
          for cloud in aws azure gcp; do
            for layer in providers server; do
              [ -d "$layer/$cloud" ] || continue
              while IFS= read -r d; do
                base=$(basename "$d")
                case "$base" in ${cloud}*) echo "cloud-prefixed dir: $d"; fail=1;; esac
              done < <(find "$layer/$cloud" -mindepth 1 -type d)
            done
          done
          exit $fail

(adjust to match the recursion/exclusions you intend). Everything else is good to go once this is sorted.

@NitinKumar004

Copy link
Copy Markdown
Collaborator Author

Thanks for the re-review. The Structure-job regression you flagged was fixed in 50d2d9c — the inline check block hadn't landed in ci.yml (only the script deletion did, in e8ecffc); that commit inlines it for real. All CI is green now: Structure, Build & Vet, Test, Lint, Format, Tidy, Contrib all ✅. Nothing else outstanding.

@thzgajendra thzgajendra left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — 50d2d9c verified ✅

The Structure-job regression is fully fixed. ci.yml now carries the real inline check (no dangling scripts/ reference), and it's the hardened, recursive version — find "$layer/$cloud" -mindepth 1 -type d catches a redundant cloud prefix at any depth, so a promoted sub-surface subdir can't reintroduce one.

Verified beyond the diff:

  • Ran the inline block against the tree → fail=0 (passes, no cloud-prefixed dirs remain).
  • Negative control → the case "$cloud"?* pattern correctly matches a would-be azurefoo, so the gate actually enforces (not a green no-op).
  • Live CI is all green: Structure ✅, Build & Vet ✅, Test ✅, Lint ✅, Format ✅, Tidy ✅, CodeQL / gosec / govulncheck / Dependency Review / Contrib ✅.

That closes every item from all three rounds — behavior-preserving rename, docs synced, field/filename consistency, STRUCTURE.md precision + documented exceptions, and a working, recursive Structure gate. Nothing outstanding on my end. LGTM — merge call is yours.

@NitinKumar004
NitinKumar004 merged commit 021ba8b into development Aug 6, 2026
12 checks passed
@NitinKumar004
NitinKumar004 deleted the feat/structure-convention branch August 6, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants